package com.ruoyi.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.project.domain.entity.ProjectGoods;
import com.ruoyi.project.domain.entity.ProjectStore;
import com.ruoyi.project.domain.query.ProjectGoodsQuery;
import com.ruoyi.project.domain.query.ProjectStoreQuery;
import com.ruoyi.project.mapper.ProjectGoodsMapper;
import com.ruoyi.project.mapper.ProjectStoreMapper;
import com.ruoyi.project.service.IProjectGoodsService;
import com.ruoyi.project.service.IProjectStoreService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class ProjectStoreServiceImpl extends ServiceImpl<ProjectStoreMapper, ProjectStore> implements IProjectStoreService {
    @Resource
    private ProjectStoreMapper projectStoreMapper;


    @Override
    @Async("taskExecutor") // 指定使用的线程池
    public void syncData(List<ProjectStore> list) {
        this.saveBatch(list); //更新或添加
    }
    @Override
    public List<ProjectStore> getList(ProjectStoreQuery query) {
        LambdaQueryWrapper<ProjectStore> wrapper = new QueryWrapper<ProjectStore>().lambda()
                .eq(query.getGoodsId()!=null,ProjectStore::getGoodsId,query.getGoodsId());
        return this.list(wrapper);
    }

    @Override
    public Boolean addInfo(ProjectStore project) {
        return   this.save(project);
    }

    @Override
    public Boolean updateInfo(ProjectStore project) {
        return  this.updateInfo(project);
    }

    @Override
    public Boolean deleteInfo(String id) {
        return  this.removeById(id);
    }

    @Override
    public ProjectStore getInfoById(String id) {
        return this.getById(id);
    }

    @Override
    public void deleteAll(){
        projectStoreMapper.deleteAll();
    }

    @Override
    public TableDataInfo getStorePage(ProjectStoreQuery query) {
        projectStoreMapper.selectStorePage(query);


        return null;
    }

}
